﻿namespace Jhong.FunMVC
{
    using System;
    using System.Collections.Generic;

    public class ViewDataDictionory
    {
        private IDictionary<string, object> _dic = new Dictionary<string, object>();

        public object this[string key]
        {
            get
            {
                object result;
                this._dic.TryGetValue(key, out result);
                return result;
            }
            set
            {
                if (this._dic.Keys.Contains(key)) throw new ArgumentException("key已经存在");
                this._dic.Add(key, value);
            }
        }

        public ICollection<object> Values
        {
            get
            {
                return this._dic.Values;
            }
        }

        public int Count
        {
            get
            {
                return this._dic.Count;
            }
        }

        public ICollection<string> Keys
        {
            get
            {
                return this._dic.Keys;
            }
        }

        public bool Remove(string key)
        {
            return this._dic.Remove(key);
        }

        public void Clear()
        {
            this._dic.Clear();
        }
    }
}